/**
 * Accepts an array which might have the duplicate items and returns an array with unique items along.
 * @param array The array which might have the duplicate items.
 * @returns An array with unique items along.
 */
export function getUniqueArray(array: any[]): any[] {
  return array.filter((value: any, index: number, self: any[]) => self.indexOf(value) === index);
}

export function* generateFilter<T>(list: T[], predicate: (item: T) => boolean): Generator<T> {
  for (const item of list) {
    if (predicate(item)) {
      yield item;
    }
  }
}

export function* generateMap<T, U>(list: T[], callbackfn: (item: T) => U): Generator<U> {
  for (const item of list) {
    yield callbackfn(item);
  }
}
